package com.billy.ohos.swipe.consumer;

import com.billy.ohos.swipe.ResourceTable;
import com.billy.ohos.swipe.SmartSwipeWrapper;
import com.billy.ohos.swipe.internal.SwipeHelper;

import ohos.aafwk.ability.Ability;

/**
 * @author billy.qi
 */
public class AbilityShuttersBackConsumer extends ShuttersConsumer {
    protected Ability mAbility;

    public AbilityShuttersBackConsumer(Ability ability) {
        this.mAutoCloseOnWrapperDetachedFromWindow = false;
        this.mAbility = ability;
    }

    @Override
    public void onAttachToWrapper(SmartSwipeWrapper wrapper, SwipeHelper swipeHelper) {
        super.onAttachToWrapper(wrapper, swipeHelper);
    }

    @Override
    public void onSwipeAccepted(int activePointerId, boolean settling, float initialMotionX, float initialMotionY) {
        super.onSwipeAccepted(activePointerId, settling, initialMotionX, initialMotionY);
    }

    @Override
    protected void onDisplayDistanceChanged(int distanceXToDisplay, int distanceYToDisplay, int dx, int dy) {
        super.onDisplayDistanceChanged(distanceXToDisplay, distanceYToDisplay, dx, dy);
    }

    @Override
    public void onDetachFromWrapper() {
        super.onDetachFromWrapper();
    }

    @Override
    protected void onOpened() {
        super.onOpened();
        if (mListeners == null || mListeners.isEmpty()) {
            if (mAbility != null) {
                mAbility.terminateAbility();
                mAbility.setTransitionAnimation(ResourceTable.Animation_anim_none, ResourceTable.Animation_anim_none);
            }
        }
    }

    @Override
    protected void onClosed() {
        super.onClosed();
    }

    @Override
    public int clampDistanceVertical(int distanceY, int dy) {
        return super.clampDistanceVertical(distanceY, dy);
    }

    @Override
    public int clampDistanceHorizontal(int distanceX, int dx) {
        return super.clampDistanceHorizontal(distanceX, dx);
    }

}
